package com.apes.scm.masterdata.finance.model;

import com.apes.framework.jpa.DefaultPersistListener;
import com.apes.framework.jpa.Model;
import com.apes.framework.jpa.Name;
import com.apes.framework.jpa.comment.Comment;
import com.apes.framework.jpa.generator.ApesGenerator;
import com.apes.framework.jpa.generator.Implementation;
import com.apes.framework.plugin.soe.annotations.State;
import com.apes.framework.plugin.soe.annotations.States;
import com.apes.scm.masterdata.enumeration.model.Enumeration;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SelectBeforeUpdate;

import javax.persistence.*;

/**
 * @desc 收款方式
 *
 * @author wuq
 * @create 2018-03-22 14:31
 */
@Getter
@Setter
@SelectBeforeUpdate
@DynamicInsert
@DynamicUpdate
@Entity
@EntityListeners(DefaultPersistListener.class)
@Table(name = "mas_payment_method")
public class PaymentMethodType extends Model {

    @Id
    @Column(name = "id", length = 8)
    @ApesGenerator(code = "mas_payment_method", name = "收付款类型", implementation = Implementation.NO_GAP, padding = 3 )
    @Comment("收款方式编码")
    private String id;  //收款方式编码

    @Column(name = "name", nullable = false, length = 64)
    @Comment("收款方式名称")
    private String name; //收款方式名称

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "payment_type", referencedColumnName = "id")
    @Comment("收款类型")
    private Enumeration paymentType;  //收款类型(paymentType)(pt_cash:现金, pt_alipay: 支付宝)

    @States(name = "收款方式分类", values = {
            @State(id = "customer", name = "收款"),
            @State(id = "supplier", name = "付款"),
            @State(id = "both", name = "收款或付款")})
    @Column(name = "payment_Method_Class", length = 64)
    private String paymentMethodClass;

    @Column(name = "retail_valid", nullable = false, columnDefinition = "number(1,0) default 1")
    @Comment("零售有效")
    private boolean retailValid = true; //零售有效

    @Column(name = "distribution_valid", nullable = false, columnDefinition = "number(1,0) default 1")
    @Comment("分销有效")
    private boolean distributionValid = true; //分销有效

    @Column(name = "payment_valid", nullable = false, columnDefinition = "number(1,0) default 1")
    @Comment("缴款有效")
    private boolean payment = false;//缴款有效

    @Name()
    @Column(name = "collection", nullable = false, columnDefinition = "number(1,0) default 1")
    @Comment("代收款")
    private boolean collection = false; //代收款标记用于平台凭证结转

    @Column(name = "valid", nullable = false, columnDefinition = "number(1,0) default 1")
    @Comment("有效")
    private boolean valid = true; //有效

}
